﻿using System;
using System.Disposables;
using System.Windows;
using System.Windows.Controls;
using SoftSource.MVVMC;
using SoftSource.Reactive;
using SoftSource.Timecard.ViewModelInterfaces;

namespace SoftSource.Timecard.Views
{
    public partial class EntriesFlaggedForAdminView : UserControl, IDisposable, IView<IEntriesFlaggedForAdminViewModelConsume>
    {
        #region Fields
        private CompositeDisposable compositeDisposable;
        #endregion Fields

        public EntriesFlaggedForAdminView()
        {
            InitializeComponent();

            this.compositeDisposable = new CompositeDisposable();

            Loaded += new RoutedEventHandler(EntriesFlaggedForAdminView_Loaded);
        }

        void EntriesFlaggedForAdminView_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.ViewModel != null)
            {
                this.ViewModel.Load // Load the data required to use this ViewModel
                    .Nullable()
                    .Subscribe();
            }
        }

        #region IView<IEntriesFlaggedForAdminViewModelConsume> Members

        public IEntriesFlaggedForAdminViewModelConsume ViewModel
        {
            get { return this.DataContext as IEntriesFlaggedForAdminViewModelConsume; }
            set { this.DataContext = value; }
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            this.compositeDisposable.Dispose();
            GC.SuppressFinalize(this);
        }

        #endregion

        ~EntriesFlaggedForAdminView()
        {
            this.Dispose();
        }
    }
}
